package com.geekstudy.week3.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedHashMap;
import java.util.Map;

@RestController
public class Week3Controller {

    final Logger logger = LoggerFactory.getLogger(Week3Controller.class);

    @RequestMapping(path = "/week3/{router}")
    public Map<String, String> week3(@PathVariable(value = "router") String router,
                                     @RequestParam(name = "name") String name) {
        Map<String, String> resultMap = new LinkedHashMap<String, String>();
        logger.info("week3 router:{} name:{} ", router, name);
        resultMap.put("router", router);
        resultMap.put("name", name);
        resultMap.put("message", "Hello " + name + " from " + router);
        return resultMap;
    }
}
